<?PHP
include("../public/common.php");
include("../config/connect.php");

$itemid = CheckUrlParamNoDie("id");
$userid = CheckUrlParamNoDie("userid");
$opt = CheckUrlParamNoDie("opt");

if ($itemid == "" || $opt == "" || $userid == "")
	exit;

//
if ($opt == "favorite") //商品我喜欢数
{
	if (mysql_num_rows(mysql_query("select id from tsj_favorite where user_id=$userid and item_id=$itemid limit 1")) == 0)
	{
		mysql_query( "update goods_items set favorite=favorite+1 where id=$itemid" );
		mysql_query( "insert tsj_favorite (user_id,item_id) values ($userid, $itemid)" );
		echo 1;
	}
	else
	{
		echo 2;
	}
}
else if ($opt == "hits") //商品点击率
{
	mysql_query( "update goods_items set hits=hits+1 where id=$itemid" );
	echo 1;
}

?>